package lib.FileSystem;

import java.io.File;
import java.util.Stack;

public class Make {
	/**
	 * Directory funtions.
	 */
	public static void CREATE_DIR(String name) {
		File dir = new File(name);
		dir.mkdir();
	}

	public static void CLEAR_DIR(String name) {
		File dir = new File(name);
		File[] currList;
		Stack<File> stack = new Stack<File>();
		stack.push(dir);
		while (!stack.isEmpty()) {
			if (stack.lastElement().isDirectory()) {
				currList = stack.lastElement().listFiles();
				if (currList.length > 0) {
					for (File curr : currList) {
						stack.push(curr);
					}
				} else {
					stack.pop().delete();
				}
			} else {
				stack.pop().delete();
			}
		}
	}
}
